package com.tommy.jiami.view;

import android.content.*;
import android.util.*;
import android.widget.*;
import android.graphics.*;
import android.view.*;

public class FrameCheckableLayout extends FrameLayout implements Checkable
{
	private LinearLayout colorLayout;
	private boolean isChecked;
	
	public FrameCheckableLayout(Context context,AttributeSet attrs){
		super(context,attrs);
	}

	@Override
	protected void onFinishInflate()
	{
		super.onFinishInflate();
		colorLayout=new LinearLayout(getContext());
		colorLayout.setLayoutParams(new ViewGroup.LayoutParams(-2,-2));
		colorLayout.setBackgroundColor(0xff00bbff);
		colorLayout.setAlpha(0);
		addView(colorLayout,new ViewGroup.LayoutParams(-1,-1));
	}
	
	@Override
	public void setChecked(boolean isChecked)
	{
		this.isChecked=isChecked;
		colorLayout.setAlpha(isChecked?0.5f:0);
	}

	@Override
	public boolean isChecked()
	{
		return isChecked;
	}

	@Override
	public void toggle()
	{
		setChecked(!isChecked);
	}

}
